using micromsg;
using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using MicroMsg.Protocol;
using System;
namespace MicroMsg.Scene
{
	public class NetScenePushChannelReg : NetSceneBaseEx<WinphoneRegRequest, WinphoneRegResponse, WinphoneRegRequest.Builder>
	{
		private const string TAG = "NetScenePushChannelReg";
		public void doScene(string string_0)
		{
			if (this.mSessionPack != null)
			{
				return;
			}
			Log.smethod_4("NetScenePushChannelReg", string.Concat(new object[]
			{
				"register push channel to mmweb-server..... uin =",
				AccountMgr.getCurAccount().nUin,
				", name = ",
				AccountMgr.getCurAccount().strUsrName
			}));
			base.beginBuilder();
			this.mBuilder.BaseRequest = NetSceneBase.makeBaseRequest(0);
			this.mBuilder.Uri = string_0;
			this.mSessionPack.mConnectMode = 2;
			this.mSessionPack.mCmdUri = "/cgi-bin/micromsg-bin/winphonereg";
			base.endBuilder();
		}
		protected override void onFailed(WinphoneRegRequest request, WinphoneRegResponse response)
		{
			Log.smethod_1("NetScenePushChannelReg", "register push channel failed. ");
		}
		protected override void onSuccess(WinphoneRegRequest request, WinphoneRegResponse response)
		{
			RetConst ret = (RetConst)response.BaseResponse.Ret;
			if (ret == RetConst.MM_OK)
			{
				Log.smethod_4("NetScenePushChannelReg", "register push channel success.  ");
				ServiceCenter.pushNotifyMgr.regCompleted = true;
				ServiceCenter.pushNotifyMgr.waitPushEvent.Set();
				PushChannelSettings pushChannelSettings = GConfigMgr.smethod_0<PushChannelSettings>();
				pushChannelSettings.strRegChannelUri = request.Uri;
				pushChannelSettings.strPushUsrName = AccountMgr.getCurAccount().strUsrName;
				GConfigMgr.save<PushChannelSettings>(true);
				ServiceCenter.pushNotifyMgr.resetOpenPushChannelTimeout();
				EventCenter.postEvent(EventConst.ON_NETSCENE_PUSHCHANNEL_REG_OVER, true, null);
				return;
			}
			Log.smethod_1("NetScenePushChannelReg", "register push channel failed,ret = " + ret);
		}
	}
}
